E:/E+I/Informatik/Projekte/FH/n-Damen Problem/menu.c File Reference

#include "ndame.h"

Go to the source code of this file.

Functions

int menu (struct data *d1)
 menu


Detailed Description

PURPOSE: file contains the menu function

Author:
Daniel Hasemann
Version:
1.0
Date:
December 16th, 2005

Definition in file menu.c.


Function Documentation

int menu struct data d1  ) 
 

menu

In the menu you can choose between calculate, options and exit. After pressing (C) youŽll start the algorithm to calculate the solutions of n-queens problem. When you press (O) the programme starts a sub menu called options. You can exit the programme with (E).

Parameters:
*d1 is a struct pointer
Returns:
ichscan is an integer
See also:
main()
Author:
Daniel Hasemann
Date:
December 16th, 2005

Definition at line 24 of file menu.c.

Referenced by main().

00025 {
00026     char chscan;
00027     int ii;
00028     int ik;
00029     int ichscan;
00030     int ic;
00031     
00032     gotoxy(5,2);
00033     printf("<C>alculate");
00034     gotoxy(25,2);
00035     printf("<O>ptions");
00036     gotoxy(47,2);
00037     printf("<E>xit");
00038     
00039     do
00040     {
00041         chscan=getch();
00042     }while(!((chscan=='c')||(chscan=='o')||(chscan=='e')));
00043     
00044     ichscan=(int)chscan;
00045     
00046     if(chscan=='c')
00047     {
00048         gotoxy(25,2);
00049     printf("         ");                              //clear options
00050     }
00051     
00052     if(chscan=='o')                                   
00053     {
00054         gotoxy(5,2);
00055     printf("           ");                            //clear calculate
00056     }
00057     
00058     if(chscan=='e')
00059     {
00060         return 0;
00061     }
00062     switch(chscan)
00063     {
00064         case 'c':
00065         d1->isolutions=0;
00066         for(ii=0;ii<MAX_SIZE;ii++)                    //queen - array will be cleared
00067         {
00068             for(ik=0;ik<MAX_SIZE;ik++)
00069             {
00070                 d1->iboard[ii][ik]=0;
00071             }
00072         } 
00073         d1->tstart=clock();                           //start time
00074         
00075         if(d1->m1==manual)
00076         {
00077             chessboard(d1);                           //chessboard view when singlestep is active
00078         }
00079         
00080         calculate(d1,0);                              //calculate starts by row=0
00081         d1->tend=clock();                             //stop time
00082         d1->fcalctime=(float)(d1->tend-d1->tstart)/CLOCKS_PER_SEC;       //time in ms
00083         d1->iauthor=0;                                //after algorithm text-file-header will activated 
00084         state(d1,6);                                  //status of calctime
00085         
00086         if(d1->m1==manual)
00087         {
00088             clrbox(0);                                //clear left box
00089             clrbox(1);                                //clear right box
00090         }
00091         break;
00092     
00093         case 'o':
00094         options(d1);                                  //sub menu options
00095         break;
00096     }
00097     return ichscan;                                   //menu loop variable
00098 }


Generated on Sun Dec 18 19:26:14 2005 for n-Queens Problem by  doxygen 1.4.5